<?php

Yii::import('application.models._base.BaseCategory');

class Category extends BaseCategory
{
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
    //获取hot 标签  在标签选择中
    public function getPublicCategory(){
        $value = Yii::app()->cache->get('TuTuPublicCategory');
        if($value === false){
            $data = Yii::app()->db->createCommand()
                ->select('id,title_cn,title_en')
                ->from('{{category}}')
                ->where('is_open=:is_open AND type=:type', array(':is_open'=>1,':type'=>'public'))
                ->order('list_order asc')
                ->queryAll();
            foreach($data as $v){
                $value[$v['title_en']]['id'] = $v['id'];
                $value[$v['title_en']]['title_cn'] = $v['title_cn'];
            }
            Yii::app()->cache->set('TuTuPublicCategory',$value);
        }
        return $value;
    }
    public function getOneCategory($category_id){
        $value = Yii::app()->db->createCommand()
            ->select('title_cn,title_en')
            ->from('{{category}}')
            ->where('id=:id AND is_open=:is_open AND type=:type', array(':id'=>$category_id,':is_open'=>1,':type'=>'public'))
            ->order('list_order asc')
            ->queryRow();
        return $value;
    }
}